<?php
if (! defined('IN_STUCLOUD') || ! defined('IN_ADMIN')) {
    die('访问受限');
}
if (! hasPermission("admin_general")) {
    errorMessage("你没有权限这样做。");
}
errorMessage("你没有权限这样做。");
global $_G;
$op = isset($_G["admin"]["op"]) ? $_G["admin"]["op"] : "";
if ($op == "menu") {
    if (isAjaxRequest()) {
        die(json_encode(array(
            "state" => 1,
            "rootURL" => "admin.php?ajax=true&model=member&op=",
            "list" => array(

                "perm" => "用户权限",
                "chenge" => "修改用户",
                "del" => "删除用户",
                "search" => "查找用户",
                "add" => "添加用户"
            ),
            "main" => "add"
        )));
        return;
    }
}

if ($op == "general") {
    loadTemp("admin/models/member/general_op_temp.php", false);
}
if ($op == "search") {
    loadTemp("admin/models/member/search_op_temp.php", false);
}
if ($op == "add") {
    errorMessage("你没有权限这样做。");
    //loadTemp("admin/models/member/add_op_temp.php", false);
}
if ($op == "del") {
    loadTemp("admin/models/member/del_op_temp.php", false);
}
if ($op == "chenge") {
    loadTemp("admin/models/member/chenge_op_temp.php", false);
}
if ($op == "perm") {
    loadTemp("admin/models/member/perm_op_temp.php", false);
}
if ($op == "addpost") {
    $name = get_post("name");
    $mail = get_post("mail");
    $password = get_post("password");
    $passdirectly = get_post("passdirectly");
    $sendMail = get_post("sendverifyemail");
    if ($name == "" || $mail == "" || $password == "") {
        die(json_encode(array(
            "child" => 1,
            "state" => 0,
            "message" => "姓名，邮箱，密码不能空缺上传"
        )));
    }
    if (register($name, $password, $mail, false)) {
        if ($passdirectly == "on") {
            setVerifyState($mail, "1");
        }
        if ($sendMail == "on") {
            if (! sendVerifyMail($name, $mail)) {
                die(json_encode(array(
                    "child" => 1,
                    "state" => 1,
                    "message" => "注册成功，验证邮件已经成功发送到:$mail"
                )));
            } else {
                die(json_encode(array(
                    "child" => 1,
                    "state" => 0,
                    "message" => "注册成功，但是验证邮件发送失败。\n请检查邮件地址:$mail 是否正确\n如果需要重置请删除账户后重新创建。"
                )));
            }
        }
        die(json_encode(array(
            "child" => 1,
            "state" => 1,
            "message" => "注册成功"
        )));
    } else {
        die(json_encode(array(
            "child" => 1,
            "state" => 0,
            "message" => "该邮箱已经被注册过了"
        )));
    }
}

?>